package com.ruoyi.system.controller.recon;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.RpaConfig;
import com.ruoyi.system.service.IRpaConfigService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 全局变量Controller
 * 
 * @author ruoyi
 * @date 2022-03-04
 */
@RestController
@RequestMapping("/recon/config")
public class RpaConfigController extends BaseController
{
    @Autowired
    private IRpaConfigService rpaConfigService;

    /**
     * 查询全局变量列表
     */
    @RequiresPermissions("recon:config:list")
    @GetMapping("/list")
    public TableDataInfo list(RpaConfig rpaConfig)
    {
        startPage();
        List<RpaConfig> list = rpaConfigService.selectRpaConfigList(rpaConfig);
        return getDataTable(list);
    }

    /**
     * 导出全局变量列表
     */
    @RequiresPermissions("recon:config:export")
    @Log(title = "全局变量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RpaConfig rpaConfig)
    {
        List<RpaConfig> list = rpaConfigService.selectRpaConfigList(rpaConfig);
        ExcelUtil<RpaConfig> util = new ExcelUtil<RpaConfig>(RpaConfig.class);
        util.exportExcel(response, list, "全局变量数据");
    }

    /**
     * 获取全局变量详细信息
     */
    @RequiresPermissions("recon:config:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rpaConfigService.selectRpaConfigById(id));
    }

    /**
     * 新增全局变量
     */
    @RequiresPermissions("recon:config:add")
    @Log(title = "全局变量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RpaConfig rpaConfig)
    {
        return toAjax(rpaConfigService.insertRpaConfig(rpaConfig));
    }

    /**
     * 修改全局变量
     */
    @RequiresPermissions("recon:config:edit")
    @Log(title = "全局变量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RpaConfig rpaConfig)
    {
        return toAjax(rpaConfigService.updateRpaConfig(rpaConfig));
    }

    /**
     * 删除全局变量
     */
    @RequiresPermissions("recon:config:remove")
    @Log(title = "全局变量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rpaConfigService.deleteRpaConfigByIds(ids));
    }
}
